home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / MLTE SDK / MLTESampleCarbon / MLTESampleCarbon.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-03  |  4.9 KB  |  152 lines  |  [TEXT/CWIE]

  1. /*
  2.     You may incorporate this sample code into your applications without
  3.     restriction, though the sample code has been provided "AS IS" and the
  4.     responsibility for its operation is 100% yours.  However, what you are
  5.     not permitted to do is to redistribute the source as "Apple Sample Code"
  6.     after having made changes. If you're going to re-distribute the source,
  7.     we require that you make it clear in the source that the code was
  8.     descended from Apple Sample Code, but that you've made changes.
  9.  
  10.     Copyright © 1998-1999 Apple Computer, Inc., All Rights Reserved
  11. */
  12. #include <CodeFragments.h>
  13. #include <Dialogs.h>
  14. #include <Events.h>
  15. #include <Gestalt.h>
  16. #include <MacTextEditor.h>
  17. #include <ToolUtils.h>
  18.  
  19. void main(void);
  20. void Initialize(void);
  21. void InitMLTE(void);
  22. void AlertUser(short error);
  23. void EventLoop(void);
  24. void DoEvent(EventRecord *event);
  25. void AdjustCursor(RgnHandle region);
  26. void DoGrowWindow(WindowPtr window, EventRecord *event);
  27. void DoZoomWindow(WindowPtr window, short part);
  28. void DoUpdate(WindowPtr window);
  29. void DoActivate(WindowPtr window, Boolean becomingActive);
  30. void DoContentClick( WindowPtr window, EventRecord *event);
  31. void DoKeyDown(EventRecord *event);
  32. static UInt32 GetSleep(void);
  33. void DoIdle(void);
  34. void AdjustMenus(void);
  35. void DoMenuCommand(long menuResult);
  36. void DoJustification(WindowPtr window, short menuItem);
  37. void DoWordWrap(WindowPtr window);
  38. OSStatus DoNew(const FSSpec *fileSpecPtr);
  39. Boolean DoCloseWindow( WindowPtr window);
  40. void Terminate(void);
  41. void BigBadError(short error);
  42. Boolean IsAppWindow(WindowPtr window, TXNObject *object);
  43. Boolean IsDAWindow(WindowPtr window);
  44. void InstallAppleEventHandlers(void);
  45. pascal OSErr HandleOapp (const AppleEvent *aevt, AEDescList *reply, UInt32 refCon);
  46. pascal OSErr HandleOdoc (const AppleEvent *aevt, AEDescList *reply, UInt32 refCon);
  47. pascal OSErr HandlePdoc (const AppleEvent *aevt, AEDescList *reply, UInt32 refCon);
  48. pascal OSErr HandleQuit (const AppleEvent *aevt, AEDescList *reply, UInt32 refCon);
  49.  
  50. // GInBackground is maintained by our OSEvent handling routines. Any part of
  51. // the program can check it to find out if it is currently in the background.
  52. Boolean    gInBackground;        // maintained by Initialize and DoEvent
  53.  
  54. // GNumDocuments is used to keep track of how many open documents there are
  55. // at any time. It is maintained by the routines that open and close documents.
  56. short    gNumDocuments;        // maintained by Initialize, DoNew, and DoCloseWindow
  57.  
  58. // Constants to identify menus and their items.
  59. #define    mApple                    128        // Apple menu
  60. #define    iAbout                    1
  61.  
  62. #define    mFile                    129        // File menu
  63. #define    iNew                    1
  64. #define    iClose                    4
  65. #define    iPageSetup                9
  66. #define    iPrint                    10
  67. #define iQuitSeparator            11
  68. #define    iQuit                    12
  69.  
  70. #define    mEdit                    130        // Edit menu
  71. #define    iUndo                    1
  72. #define    iCut                    3
  73. #define    iCopy                    4
  74. #define    iPaste                    5
  75. #define    iClear                    6
  76. #define    iSelectAll                8
  77.  
  78. #define    mFont                     131        // Font menu
  79.  
  80. #define    mSize                    132        // Size menu
  81. #define    i9Point                    1
  82. #define    i10Point                2
  83. #define    i12Point                3
  84. #define    i14Point                4
  85. #define    i18Point                5
  86. #define    i24Point                6
  87. #define    i36Point                7
  88. #define    iSmallerFontSize        9
  89. #define    iLargerFontSize            10
  90. #define    iOtherFontSize            12
  91.  
  92. #define    mStyle                    133        // Style menu
  93. #define    iPlain                    1
  94. #define    iBold                    2
  95. #define    iItalic                    3
  96. #define    iUnderline                4
  97. #define    iOutline                5
  98. #define    iShadow                    6
  99. #define    iCondensed                7
  100. #define    iExtended                8
  101.  
  102. #define    mLayout                    134        // Format menu
  103. #define    iDefaultJustify            1
  104. #define    iLeftJustify            2
  105. #define    iRightJustify            3
  106. #define    iCenterJustify            4
  107. #define    iFullJustify            5
  108. #define    iForceJustify            6
  109. #define    iAutoWrap                8
  110.  
  111. TXNFontMenuObject gTXNFontMenuObject;
  112.  
  113. #define kDefaultFontName    "\pNew York"
  114.  
  115. const short    kStartHierMenuID = 160;
  116.  
  117. // For positioning disk initialization dialogs
  118. #define kDITop                    0x0050
  119. #define kDILeft                    0x0070
  120.  
  121. /* kMaxOpenDocuments is used to determine whether a new document can be opened
  122.    or created. We keep track of the number of open documents, and disable the
  123.    menu items that create a new document when the maximum is reached. If the
  124.    number of documents falls below the maximum, the items are enabled again. */
  125. #define    kMaxOpenDocuments        1
  126.  
  127. /* The following are indicies into STR# resources. */
  128. #define    eWrongSystem                1
  129. #define    eNoMemory                    2
  130. #define    eNoCut                        3
  131. #define    eNoCopy                        4
  132. #define    eNoClear                    5
  133. #define    eNoWindow                    6
  134. #define    eNoPaste                    7
  135. #define    eNoMLTE                        8
  136. #define eNoAttachObjectToWindow     9
  137. #define eNoActivate                    10
  138. #define eObjectNotAttachedToWindow    11
  139. #define    eNoFontName                    12
  140. #define    eNoFontSize                    13
  141. #define    eNoFontStyle                14
  142. #define    eNoJustification            15
  143. #define eNoDisposeFontMenuObject    16
  144. #define    eNoWordWrap                    17
  145.  
  146. #define    rMenuBar    128                /* application's menu bar */
  147. #define    rAboutAlert    128                /* about alert */
  148. #define    rUserAlert    129                /* user error alert */
  149. #define    rDocWindow    128                /* application's window */
  150. #define    kErrStrings    128                /* error string list */
  151.  
  152.